package 背包问题求方案数;

import java.util.Scanner;

public class Main {
    static int N = 1010;
    static int[] v = new int[N];
    static int[] w = new int[N];
    static int[][] f = new int[N][N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        for (int i = 1; i <= n; i++) {
            v[i] = in.nextInt();
            w[i] = in.nextInt();
        }
        for (int i = n; i >= 1; i--) {
            for (int j = 1; j <= m; j++) {
                f[i][j] = f[i + 1][j];
                if (j >= v[i]) {
                    f[i][j] = Math.max(f[i][j], f[i + 1][j - v[i]] + w[i]);
                }
            }
        }
        int j = m;
        for (int i = 1; i <= n; i++) {
            if (j >= v[i] && f[i][j] == f[i + 1][j - v[i]] + w[i]) {
                System.out.print(i + " ");
                j -= v[i];
            }
        }
    }
}
